<?php

namespace App\Http\Controllers\Page\Customer;

use Illuminate\Http\Request;
use App\Facades\DeviceService;
use App\Facades\WeChatService;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class DeviceController extends Controller
{
    /**
     * 
     * @param  Request $request 
     * @return [type]           
     */
    public function getState(Request $request)
    {
    	$state = DeviceService::getState(false);
        if(is_null($state))
        {
            $state['deviceCode'] = deviceCode();
        }
        $host = head($request->header()['host']);
        return view('add_water')->with(wxConfig(['state' => $state, 'host' => $host], $request));
    }

    public function airKiss(Request $request)
    {
        
        return view('bind')->with(wxConfig([], $request));
    }

    public function unbind()
    {
        return view('unbind');
    }

    public function all()
    {
        $deviceList = DeviceService::getDeviceInfoListByUser();
        return view('set_infor')->with([
            'deviceList' => $deviceList,
            ]);
    }


}
